import axios from 'axios';

export default {
    install: function(Vue, options) {

        let service = {
            // 删除门票
            Remove: (userId) => {
                return axios.delete('/admin/ticket/' + userId);
            },

            // 查询符合条件的门票数量
            QueryTicketsCount: (condition) => {
                return axios.post('/admin/ticket/query/count', condition);
            },

            // 查询符合条件的门票
            QueryTickets: (condition, pageIndex, pageSize) => {
                return axios.post(`/admin/ticket/query?pageIndex=${pageIndex}&pageSize=${pageSize}`, condition);
            },

            // 导出门票列表
            ExportTickets: (condition) => {
                return axios.post('/admin/ticket/export', condition)
                    .then(ret => {
                        var link = aphf.file.ADDR + '/' + ret;

                        var a = document.createElement("a");
                        a.download = 'Tickets.xls';
                        a.href = link;
                        a.click();
                    })
            }
        }

        Vue.prototype.$TicketService = service;
    }
}